<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<title><fmt:message key="appTitle" /></title>
<link rel="stylesheet" type="text/css"
	href='<c:url value="/styles/base.css" />' />
<link rel="stylesheet" type="text/css"
	href='<c:url value="/styles/charte.css" />' />
</head>
<body>

<div id="global"><jsp:include page="header.jsp" /> <jsp:include
	page="menu.jsp" />

<div id="contenu">
<c:choose>
	<c:when test="${not empty sheet }">
		<c:set var="disabled" value="${! survey.open }"/>
		<c:set var="obligatoryQuestion" value="false"/>
		<h2>Fiche du sondage : <c:out value="${survey.title}" /></h2>
		<form:form method="post" commandName="sheetForm"
			action="?${pageContext.request.queryString}" acceptCharset="UTF-8" enctype="multipart/form-data">
			<table	cellpadding="3">

				<c:forEach var="question" items="${questions}">
					<tr>
						<td><b><c:out value="${question.title}" /> :</b>
						</td>
						<td><c:choose>
							<c:when test="${question.type == 'STRING' }">
								<form:input path="answers[${question.id }]"   disabled="${disabled}" />
								<form:errors path="answers[${question.id }]" />
							</c:when>
							<c:when test="${question.type == 'TEXT' }">
								<form:textarea path="answers[${question.id}]" disabled="${disabled}" />
								<form:errors path="answers[${question.id }]" />
							</c:when>
							<c:when test="${question.type == 'FILE' }">
								<c:if test="${disabled}"><input type="file" name="answers[${question.id }]" disabled="disabled"  /></c:if>
								<c:if test="${not disabled}"><input type="file" name="answers[${question.id }]"/></c:if>
								<form:errors path="answers[${question.id }]" />
							</c:when>
							<c:when test="${question.type == 'SIMPLECHOICE' }">
								<form:select path="answers[${question.id }]" disabled="${disabled}" >
									<c:forEach var="answer" items="${question.properties}">
										<form:option value="${answer.id}">${answer.value}</form:option>
									</c:forEach>
								</form:select>
								<form:errors path="answers[${question.id }]" />
							</c:when>

						</c:choose>
						<c:if test="${question.obligatory }">
							<span style="color:red;">*</span>
							<c:set var="obligatoryQuestion" value="true"/>
						</c:if>
						</td>
					</tr>
				</c:forEach>
				<tr>
					<td></td>
					<td><input type="submit"
						value="<fmt:message key="submit" />" disabled="${disabled}"/></td>
					<td></td>
				</tr>
			</table>
			<c:if test="${obligatoryQuestion}">
			<span style="color:red;">* <fmt:message key="obligatory-question" /></span>
			</c:if>
		</form:form>
	</c:when>
	<c:otherwise><fmt:message key="survey-not-found" /></c:otherwise>
</c:choose></div>
<jsp:include page="footer.jsp" /></div>
</body>
</html>